home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
4.1
/
menuInspector.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
5KB
|
163 lines
" NAME menuInspector
AUTHOR Bernard Horan <bernard@is.morgan.com>
CONTRIBUTOR Bernard Horan <bernard@is.morgan.com>
FUNCTION use a walking menu to inspect an object
ST-VERSIONS 4.1
PREREQUISITES TreeMenu
CONFLICTS
DISTRIBUTION world
VERSION 1.0
DATE October 1992
SUMMARY Hold down the shift key whilst selecting
inspect and you will be provided with a walking menu inspecting the
object. When you let go, you'll get an inspector on that object
(unless you hold down shift and it will start all over again).
Especially useful for VisualComponent structures. BH, 5/10/92"
'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 1 October 1992 at 6:03:23 am'!
!CharacterArray methodsFor: 'private'!
basicInspectMenu
"return a tree menu with at least some labels and appropriate values.
Optionally include a heading.
Bernard Horan, 28 September 1992"
| menu |
menu := super basicInspectMenu.
menu heading: self.
^menu! !
!String methodsFor: 'user interface'!
inspect
"Create and schedule a SequenceableCollectionInspector in which the user
can examine the receiver's variables."
"If the shift key is down, then provide the user with a TreeMenu inspection
of the object.
Bernard Horan, 28 September 1992"
InputState default shiftDown ifFalse: [SequenceableCollectionInspector openOn: self]
ifTrue: [self menuInspect]! !
!OrderedCollection methodsFor: 'user interface'!
inspect
"Create and schedule a OrderedCollectionInspector in which the user
can examine the receiver's variables."
"If the shift key is down, then provide the user with a TreeMenu inspection
of the object.
Bernard Horan, 28 September 1992"
InputState default shiftDown ifFalse: [OrderedCollectionInspector openOn: self]
ifTrue: [self menuInspect]! !
!Object methodsFor: 'user interface'!
inspect
"Create and schedule an Inspector in which the user can examine the
receiver's variables."
"If the shift key is down, then provide the user with a TreeMenu inspection
of the object.
Bernard Horan, 28 September 1992"
InputState default shiftDown ifFalse: [self basicInspect]
ifTrue: [self menuInspect]!
menuInspect
"provide a menu of my instance variables, with a suitable representation of
me as its heading.
Picking an instance variables will produce another menu, and so on....
Picking an item will cause
a real inspector to be opened (unless of course, you've got the shift key
held down).
Bernard Horan, 1 October 1992"
| target |
target := self inspectMenu startUp.
target == #noSelection ifFalse: [target inspect]! !
!Object methodsFor: 'private'!
basicInspectMenu
"return a tree menu with at least some labels and appropriate values.
Optionally include a heading.
Bernard Horan, 28 September 1992"
| menu |
menu := self isManifest
ifFalse:
[| names |
names := self class allInstVarNames.
TreeMenu labelArray: names values: ((1 to: names size)
collect: [:i | self instVarAt: i])]
ifTrue: [TreeMenu labels: self printString values: (Array with: self)].
menu heading: (self printString contractTo: 30).
^menu!
inspectMenu
"provide a menu of my instance variables, with a suitable representation of
me as its heading.
Picking an instance variables will produce another menu, and so on....
Bernard Horan, 28 September 1992"
| menu |
menu := self basicInspectMenu.
menu resultBlock: [:first :last | last == #noSelection
ifTrue: [first]
ifFalse: [last]].
menu children: (Array new: menu labels size withAll: [:t | t valueAtSelection inspectMenu]).
^menu! !
!Collection methodsFor: 'private'!
basicInspectMenu
"return a tree menu with at least some labels and appropriate values.
Optionally include a heading.
Bernard Horan, 28 September 1992"
| menu names |
names := OrderedCollection new: self size.
self do: [:i | names add: i].
menu := TreeMenu labelArray: (names collect: [:i | i printString contractTo: 30])
values: ((1 to: names size)
collect: [:i | names at: i]).
menu heading: self class printString.
^menu! !
!Dictionary methodsFor: 'user interface'!
inspect
"Create and schedule a DictionaryInspector in which the user can examine
the
receiver's variables."
"If the shift key is down, then provide the user with a TreeMenu inspection
of the object.
Bernard Horan, 28 September 1992"
InputState default shiftDown ifFalse: [Cursor wait showWhile: [DictionaryInspector openOn: self]]
ifTrue: [self menuInspect]! !
!Dictionary methodsFor: 'private'!
basicInspectMenu
"return a tree menu with at least some labels and appropriate values.
Optionally include a heading.
Bernard Horan, 28 September 1992"
| menu names |
names := self keys asOrderedCollection.
menu := TreeMenu labelArray: (names collect: [:i | i printString contractTo: 30])
values: (names collect: [:i | self at: i]).
menu heading: self class printString.
^menu! !